<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>限时抢购</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <style>
    html,
    body {
        height: 140px
    }
    .jb .title{
      width: 100%;
      text-align: center;
      line-height: 80px;
      margin-bottom: 60px;
      color:#fff;
      position: relative;
      display: flex;
      text-align: center;
      align-items: center;
      justify-content: center;
    }
    .jb .title>div{
      position: absolute;
      left:10px;
      font-size: .8rem;
    }
    #ulList .aui-list-item-media , #ulList .aui-list-item{
        padding:0;
    }
    #ulList .aui-list-item-media {
        padding:.5rem;
        width: 6rem;
    }
    #ulList .aui-list-item-title {
        font-size: .6rem;
    }
    #ulList .aui-list-item-text1 {
        font-size: .6rem
    }
    #ulList .aui-list-item-text1 span {
        font-size: .8rem;
        color:red;
    }
    #ulList .aui-list-item-text2 {
        text-decoration:line-through;
        font-size: .5rem;
        color:#ccc;
    }
    #ulList .aui-list-item-text3 {
        font-size: .6rem;
        display: flex;
        text-align: center;
        align-items: center;
        justify-content: space-between;
    }
    #ulList .aui-list-item-text3 span {
      border-radius: 5px;
      padding: .25rem .5rem;
      background-color: red;
      color:#fff;
    }
    #ulList .aui-list-item-media img{
        width: 100%;
        height: 100%;
        border-radius: 5px;
    }

    </style>
</head>

<body class="jb">
  <h2 class='title'>
    <div onclick="closeWin();">
        <span class="aui-iconfont aui-icon-left"></span>&nbsp;&nbsp;返回
    </div>
    限时秒杀
  </h2>
  <div class="aui-content aui-margin-b-15">
    <ul class="aui-list aui-media-list" id="ulList">
        <!-- <li class="aui-list-item">
            <div class="aui-media-list-item-inner">
                <div class="aui-list-item-media">
                    <img src="../../image/demo1.png">
                </div>
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title">带有媒体的列表二</div>
                    </div>
                    <div class="aui-list-item-text1">
                        已抢<span>1000</span>件
                    </div>
                    <div class="aui-list-item-text2">
                        原价
                    </div>
                    <div class="aui-list-item-text3">
                        <div>券后</div>
                        <span>马上抢</span>
                    </div>
                </div>
            </div>
        </li> -->
    </ul>
  </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js" ></script>
<script type="text/javascript" src="../script/common.js" ></script>
<script type="text/javascript" src="../script/doT.min.js" ></script>
<script type="text/javascript">
var NVNavigationBar;
apiready = function() {
    NVNavigationBar = api.require('NVNavigationBar');

    //	快抢时间点：1.昨天的0点，2.昨天10点，3.昨天12点，4.昨天15点，5.昨天20点，6.今天的0点，7.今天10点，8.今天12点，9.今天15点，10.今天20点，11.明天的0点，12.明天10点，13.明天12点，14.明天15点，15.明天20点


    var items = [
      {title: '昨天0点'},
      {title: '昨天10点'},
      {title: '昨天12点'},
      {title: '昨天15点'},
      {title: '昨天20点'},
      {title: '今天0点'},
      {title: '今天10点'},
      {title: '今天12点'},
      {title: '今天15点'},
      {title: '今天20点'},
      {title: '明天0点'},
      {title: '明天10点'},
      {title: '明天12点'},
      {title: '明天15点'},
      {title: '明天20点'},
    ];
    for (var i = 0; i < items.length; i++) {
      items[i].bg='rgba(255,255,255,0)'
      items[i].bgSelected='#fff'
    }
    NVNavigationBar_open(items);
};

function goTodetails(data){
  //console.log(JSON.stringify(data),data.itemtitle)
  api.openWin({
    name: '详情',
    url: './limit_details.html',
    rect: {
        x: 0,
        y: 0,
        w: 'auto',
        h: 'auto'
    },
    pageParam: {
        data
    }
  });
}

function NVNavigationBar_open(items) {
    NVNavigationBar.open({
        rect: {
            x: 0,
            y: 60,
            w: api.frameWidth,
            h: 80
        },
        styles: {
            orientation: 'horizontal',
            bg: 'rgba(255,255,255,0)',
            bgAlpha: 1,
            font: {
                size: 12,
                sizeSelected: 14,
                color: '#fff',
                colorSelected: 'red',
            },
            itemSize: {
                w: api.frameWidth/5,
                h: 80
            }
        },
        items: items,
        selectedIndex: 0,
        fixedOn: api.frameName,
        fixed: false,
        id: 'first'
    }, function(ret, err) {
        //if (ret.eventType == 'click') {
          let urlTransform = window.urlTransformZGD(window.APIServerZGD.LimitTime,{timeType:ret.index+1,id:'1'})
          console.log(urlTransform)
          _Ajax(urlTransform,'get',{},'json',function(ret){
            var next_id = ret.min_id,data = ret.data,renderLi = doT.template($api.text($api.byId('templateLimit')));
            if(ret.code === 1){
              $api.html($api.byId('ulList'), '');
              $api.append($api.byId('ulList'), renderLi(ret.data));
            }else{
              console.log(JSON.stringify(ret.msg))
            }
          });
        //}
    });
}
</script>
<script id="templateLimit" type="text/x-dot-template">
    {{ for (var key in it){ }}

    <li class="aui-list-item" onclick='goTodetails( {{= JSON.stringify( it[key] ) }} )' tapmode>
        <div class="aui-media-list-item-inner">
            <div class="aui-list-item-media">
                <img src={{= it[key]['itempic']+'_500x500.jpg' }}>
            </div>
            <div class="aui-list-item-inner">
                <div class="aui-list-item-text">
                    {{= it[key]['shoptype'] == 'B' ? '<img src="../image/tmall.png" style="width:0.6rem;margin-right:5px;">':'<img src="../image/taobao.png" style="width:0.6rem;margin-right:5px;">' }}
                    <div class="aui-list-item-title">{{= it[key]['itemtitle'] }}</div>
                </div>
                <div class="aui-list-item-text1">
                    已抢<span>{{= it[key]['itemsale'] }}</span>件
                </div>
                <div class="aui-list-item-text2">
                    原价{{= it[key]['itemprice'] }}
                </div>
                <div class="aui-list-item-text3">
                    <div>券后{{= it[key]['itemendprice'] }}</div>
                    <span>马上抢</span>
                </div>
            </div>
        </div>
    </li>

    {{ } }}
</script>
</html>
